from langchain_community.utilities import SQLDatabase

USER_NAME = 'ourcrm_admin'
PWD = 'ourcrm_admin'
HOST = '172.24.30.115'
PORT = 3306
DATABASE = 'scrm_test'

def get_mysql_db(include_tables: list = None):
    try:
        mysql_uri = f'mysql+mysqldb://{USER_NAME}:{PWD}@{HOST}:{PORT}/{DATABASE}?charset=utf8mb4'
        return SQLDatabase.from_uri(mysql_uri, include_tables=include_tables)
    except Exception as e:
        print(f'数据库连接异常：{e}')
        raise

